﻿

@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Index.cshtml";
}
<style type="text/css">
    .form .formValue input.form-control {
        line-height: 32px;
        padding: 0px;
        resize: none;
        border-radius: 0px;
        box-shadow: none;
        text-indent: 5px
    }

    .textValue {
        width: 100%;
    }

    .selectbox {
        color: #444;
        line-height: 34px;
        display: block;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        height: 34px;
        width: 100%;
    }

    .search {
        margin-left: 10px;
        padding: 0px;
    }

    table td {
        height: 40px;
        line-height: 40px;
    }

    .zdyPanel {
        background-color: #fff;
        border-top: 1px solid #ddd;
        border-left: 1px solid #ddd;
        border-right: 1px solid #ddd;
        margin: 0px;
        float: left;
        width: 100%;
    }

    .zdyTool {
        float: left;
        padding-left: 10px;
        width: 100%;
    }

    .zdyBar {
        padding: 0px;
        margin: 0px;
        margin-top: 3px;
    }

    .zdyUL {
        list-style-type: none;
        margin: 5px 0px 0px -3px;
        padding: 0px;
    }

        .zdyUL li {
            float: left;
            list-style: none;
            height: 24px;
            line-height: 22px;
        }

            .zdyUL li a {
                cursor: pointer;
                padding: 5px 10px;
                border-radius: 4px;
            }

            .zdyUL li i {
                margin-right: 4px;
                font-size: 13px;
                color: #666;
                vertical-align: middle;
                margin-top: -1px;
            }

            .zdyUL li a:hover {
                text-decoration: none;
                background-color: #1ABC9C;
                color: #fff;
            }

    .autocomplete-suggestions {
        -webkit-box-sizing: border-box;
        -moz-box-sizing: border-box;
        box-sizing: border-box;
        border: 1px solid #999;
        background: #FFF;
        cursor: default;
        overflow: auto;
        -webkit-box-shadow: 1px 4px 3px rgba(50, 50, 50, 0.64);
        -moz-box-shadow: 1px 4px 3px rgba(50, 50, 50, 0.64);
        box-shadow: 1px 4px 3px rgba(50, 50, 50, 0.64);
    }

    .autocomplete-selected {
        background: #F0F0F0;
    }

    .autocomplete-suggestion {
        padding: 2px 5px;
        white-space: nowrap;
        overflow: hidden;
    }

    .autocomplete-no-suggestion {
        padding: 2px 5px;
    }

    .zdyGirdPanel {
        width: 100%;
        margin: 0px;
        padding: 0px;
        float: left;
    }

    .zdyContentPanel {
        width: 100%;
        margin: 5px 0px 0px 0px;
        padding: 0px;
        float: left;
    }

    .zdyFont {
        padding-left: 5px;
        color: #ff6a00;
    }

    .zdyUL {
        list-style-type: none;
        margin: 5px 0px 0px -3px;
        padding: 0px;
    }

        .zdyUL li {
            float: left;
            list-style: none;
            height: 24px;
            line-height: 22px;
        }

            .zdyUL li a {
                cursor: pointer;
                padding: 5px 10px;
                border-radius: 4px;
                color: #337ab7;
            }

            .zdyUL li i {
                margin-right: 4px;
                font-size: 13px;
                color: #666;
                vertical-align: middle;
                margin-top: -1px;
            }

            .zdyUL li a:hover {
                text-decoration: none;
                background-color: #1ABC9C;
                color: #fff;
            }

    .zdyGirdPanel {
        padding-top: 3px;
    }

    .form .formValue {
        padding: 1px 3px;
    }
</style>
<script>
    var resultData = {};
    $(function () {
        GetItems();
        gridList();
    });

    function btn_onSearch() {
        ReloadGridList();
    }

    function GetItems() {
        resultData = getCache("CHECK_INDEX");
        if (resultData.length <= 0) {
            $.ajax({
                url: "/CheckManager/CheckInfos/GetItemListJson",
                dataType: "json",
                async: false,
                success: function (data) {
                    resultData = data;
                    InitControl();
                    setCache("CHECK_INDEX", resultData);
                }, error: function (XMLHttpRequest, textStatus, errorThrown) {
                }
            });
        }
    }

    function gridList() {
        var $gridList = $("#gridList");
        var queryJson = {
        };
        $gridList.dataGrid({
            url: "/CheckManager/CheckInfos/GetMySignGridData",
            postData: { queryJson: JSON.stringify(queryJson) },
            height: 670,
            colModel: [
                { label: '活动主题', name: 'theme', width: 200 },
                { label: '城市', name: 'cityId', width: 120, align: 'left'},
                { label: '日期', name: 'time', width: 120 },
                { label: '单号', name: 'F_OrderId', width: 50 },
                { label: '批次号', name: 'F_No', width: 120, hidden: true },
                { label: '申请人', name: 'checkname', width: 120 },
                { label: '申请部门', name: 'checkorganize', width: 120 },
                {
                    label: '申请类型', name: 'F_ApplyType', width: 120, align: 'left', formatter: function (cellvalue) {
                        return GetDictionaries(cellvalue, 'F_ApplyType');
                    }
                },
                { label: '申请内容', name: 'content', width: 120 },
                { label: '会签人', name: 'signname', width: 120, align: 'left',hidden:true },
                {
                    label: '会签部门', name: 'signorganize', align: 'left', hidden: true, formatter: function (cellvalue) {
                        return GetDictionaries(cellvalue, 'CheckDepartment');
                    }
                },
                { label: '会签内容', name: 'F_Note', width: 120, align: 'left' },
                { label: '', name: 'F_FlowId', hidden: true },
                { label: '', name: 'F_Id', hidden: true },
                { label: '', name: 'F_ApplyType', hidden: true },
            ],
            pager: "#gridPager",
            viewrecords: true,
            multiselect: false,
            sortname: 'F_Id',
            rowNum: 20,
            rowList: [20, 40, 60],
            ondblClickRow: function (rowid, iRow, iCol, e) {
                CheckView();
            },
            loadComplete: function (data) {
            }
        });
    }

    function ReloadGridList() {
        var $gridList = $("#gridList");
        $gridList.jqGrid('setGridParam', {
        }).trigger('reloadGrid');
    }



    function CheckView() {
        var rowObj = $("#gridList").jqGridRowValue();
        if (rowObj["F_ApplyType"] == "1") {
            //场地档期审核详情
        } else if (rowObj["F_ApplyType"] == "2") {
            //场地带看审核详情
        }
        else if (rowObj["F_ApplyType"] == "3") {
            //意向场地报价申请
        } else if (rowObj["F_ApplyType"] == "4") {
            //报价单审核详情
        } else if (rowObj["ApplyTypeNo"] == "5") {

        } else if (rowObj["F_ApplyType"] == "6") {
            $.modalOpen({
                id: "checkUsing",
                title: "用印申请会签",
                url: "/CheckManager/CheckInfos/UsingSign?F_OrderId=" + rowObj["F_OrderId"] + "&F_Id=" + rowObj["F_Id"] + "&F_Note=" + rowObj["F_Note"],
                width: "1200px",
                height: "650px",
                callBack: function (iframeId) {
                    top.frames[iframeId].submitForm();
                },
                btn: ["确定", "取消"],
            });
        } else if (rowObj["F_ApplyType"] == "7") {
            //合同审核详情
        }
    }

    function GetDictionaries(value, type) {
        if (type == "F_ApplyType") {
            for (var i = 0; i < resultData.F_ApplyType.length; i++) {
                if (value == resultData.F_ApplyType[i].F_ItemCode) {
                    return resultData.F_ApplyType[i].F_ItemName;
                }
            }
            return '';
        } else if (type == "CheckDepartment") {
            for (var i = 0; i < resultData.Organize.length; i++) {
                if (value == resultData.Organize[i].F_Id) {
                    return resultData.Organize[i].F_FullName;
                }
            }
            return '';
        } else if (type == "ApplyDepartment") {
            for (var i = 0; i < resultData.Organize.length; i++) {
                if (value == resultData.Organize[i].F_Id) {
                    return resultData.Organize[i].F_FullName;
                }
            }
            return '';
        }
    }

</script>

<div class="zdyGirdPanel">
    <table id="gridList"></table>
    <div id="gridPager"></div>
</div>